import Vue from "vue";
import VueRouter from "vue-router";
import Loading from "../views/Loading.vue";
import Index from "../views/Index.vue";
import Reg from "../views/Reg.vue";
import Mine from "../views/Mine.vue";
import Ques from "../views/Ques.vue";
import AddrList from "../views/AddrList.vue";
import AddrInfo from "../views/AddrInfo.vue";
import Upload from "../views/Upload.vue";
import Lottery from "../views/Lottery.vue";
import FriendsList from "../views/FriendsList.vue";
import ScenicList from "@/views/ScenicList.vue";
import ScenicInfo from "@/views/ScenicInfo.vue";
import Store from "@/views/Store.vue";
import Order from "@/views/Order.vue";
import GoodsDetail from "@/views/GoodsDetail.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "load",
    component: Loading,
  },
  {
    path: "/index",
    name: "index",
    component: Index,
  },
  {
    path: "/reg",
    name: "reg",
    component: Reg,
  },
  {
    path: "/mine",
    name: "mine",
    component: Mine,
  },
  {
    path: "/ques",
    component: Ques,
  },
  {
    path: "/addrlist",
    component: AddrList,
  },
  {
    path: "/addrinfo",
    name: "addrinfo",
    component: AddrInfo,
  },
  {
    path: "/upload",
    name: "upload",
    component: Upload,
  },
  {
    path: "/lottery",
    name: "lottery",
    component: Lottery,
  },
  {
    path: "/friends",
    component: FriendsList,
  },
  {
    path: "/sceniclist",
    component: ScenicList,
  },
  {
    path: "/scenicinfo",
    name: "scenicinfo",
    component: ScenicInfo,
  },
  {
    path: "/store",
    component: Store,
  },
  {
    path: "/order",
    component: Order,
  },
  {
    path: "/goodsdetail",
    name: "goodsdetail",
    component: GoodsDetail,
  },
];

const router = new VueRouter({
  routes,
});

//全局路由守卫 应用场景：后台管理系统，必须登录才能跳转到主页面
// router.beforeEach((to, from, next) => {
//   console.log(to)
//   console.log(from)
//   const tokenStr = localStorage.getItem('token')
//   if (to.path === '/home' && !tokenStr) {
//     next('/login')
//   } else {
//     next()
//   }
// })
export default router;
